package com.education.admin.api.controller;

import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.common.utils.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @Author: dongyaoyao
 * @CreateTime: 2024-08-13
 * @Description:
 * @Version: 1.0
 */


public class LoginController extends BaseController {

    @PostMapping("login")
    public Result login(@RequestBody Map<String,String> params){
        String userName=params.get("userName");
        String password=params.get("password");
        String imageCode=params.get("imageCode");
        String key=params.get("key");
       String cacheCode=(String)redisTemplate.opsForValue().get(key);
        if (!cacheCode.equals(imageCode)){
            return Result.fail(new ResultCode(ResultCode.FAIL,"验证码错误"));
        }
        return null;

    }
}